import { axios } from '@/utils/ask'

// 获取留言板列表
export const getMessageBoardList = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: '/blog/messageBoard/getMessageBoardList',
      method: 'post',
      data: params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 请求最近五条留言
export const getRecentlyMessages = () => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: '/blog/messageBoard/getRecentlyMessages',
      method: 'post'
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 留言
export const leaveMessage = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: '/blog/messageBoard/leaveMessage',
      contentType: 'application/x-www-form-urlencoded',
      method: 'post',
      data: params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
